<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="com.hnas.core.util.PropertyUtil "%>
<%@page import="com.hnas.core.dto.DataBean"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${pageTitle}</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath }/static/common/multiple/easyui.css"/>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/multiple/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui.combotree.search.js"></script>
<script type="text/javascript">
	function doValid(){
		return true;
	}
</script>
<style type="text/css">
#ImportDataDiv select,#nodeId,#organTypeM{border: #dcdbdb 1px solid;height: 26px;width: 200px;border-radius: 3px;font-family: Microsoft YaHei;}
</style>
</head>
<body>
  <!-- 标题 -->
	<div class="titleBar m_b_20">
		<div class="tit fl b_l_e74a5f">
			<h3 class="cn">商户管理</h3>
			<span class="en"> Merchant Management </span>
		</div>
		<div class="fr"></div>
	</div>
  <!-- end 标题 -->
  
<form method="post" action="${pageContext.request.contextPath }/backend/merchant/search" name="searchForm" >
  <input type="hidden" name="pageNo" value="${dto.pageNo}">
  <input type="hidden" name="totalCount" value="${dto.totalCount}">
	<div class="box_03 p_20 m_b_20">
		<table class="tb_style02" width="100%">
			<tr>
			    <th style="width:200px;" hidden="hidden"></th>
               	<td style="width:160px;">
               		
                </td>
                <th style="width:160px;">名称</th>
               	<td>
               		<input type="text" style="width:160px;" name="name" id="name" value="${dto.name}" style="width:100px;" class="input_style2"/>
                </td>
                <th style="width:160px;">每页显示</th>
        		<td style="width:160px;">
        			<input style="width:50px;" class="input_style2" type="text" placeholder="" id="pageSize" name="pageSize" value="${dto.pageSize}"> 条
        		</td>
        		<th style="width:200px;" hidden="hidden"></th>
               	<td style="width:200px;">
               		
                </td>
			</tr>
		</table>
		<table class="tb_style02" width="100%">
			<tr>
			    <th style="width:200px;" hidden="hidden"></th>
               	<td style="width:200px;">
               		
                </td>
          		<td style="width:70px;">
   					<input class="btn_brown02 m_r_12" type="button" name="add" id="add" onclick="oper(-1,'add')" value="添 加">
        		</td>
        		<td style="width:70px;">
   					<input class="btn_brown02 m_r_12" type="button" name="searchData" id="searchData" value="查  询">
        		</td>
        		<th style="width:200px;" hidden="hidden"></th>
               	<td style="width:200px;">
               		
                </td>
			</tr>
		</table>
	</div>
</form>
	<div class="m_b_20">
		<table class="tb_style05" width="100%" style="table-layout:fixed;">
			<thead>
				<tr>
					<c:forEach items="${beans}" var="o">
					 <c:if test="${o.display && !o.hidden}"><th style="text-align:center;vertical-align:middle;">${o.title}</th></c:if>
					</c:forEach>
					<th width="200px" style="text-align:center;vertical-align:middle;">操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${pg.list}" var="o">
					<tr>
						<c:forEach items="${beans}" var="o1">
							<c:if test="${o1.display && !o1.hidden}">
								<td style="word-wrap:break-word;text-align:center;vertical-align:middle;">
									<%=String.valueOf(PropertyUtil.getValue(pageContext.getAttribute("o"),((DataBean)pageContext.getAttribute("o1")).getField())).replace("false","否").replace("true","是")%>
								</td>
							</c:if>
						</c:forEach>
						<td style="text-align:center;vertical-align:middle;">
							<%-- <a href="#" class="c_3366cc btn editData" onclick="oper('${o.id }','detail')">详情</a>&nbsp;&nbsp; --%>
							<a href="#" class="c_3366cc btn exportData" onclick="oper('${o.id}','edit')">编辑</a>
							<a href="#" class="c_3366cc btn exportData" onclick="oper('${o.id}','view')">查看商家</a>
							<a href="#" class="c_3366cc btn deleteData" onclick="oper('${o.id}','del')">删除</a>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	<div class="searpage" align="right">
		<div>
			${pg.pageStr} 
		</div>
	</div>
	
	
<script>
var editDivHeight = 335;
var editDivWidth = 380;
var isEditDivHeight = typeof myEditDivHeight == "undefined";
var isEditDivWidth = typeof myEditDivWidth == "undefined";
	$("#searchData").click(searchData);
	
	function searchData(){
		/** 校验输入页数是否非法  **/
		var pageSize=$("#pageSize").val();
		var reg = new RegExp("^[0-9]*$");
		if($.trim(pageSize)!=""){
			if(!reg.test($.trim(pageSize))){
				alert("每页显示数请输入非负整数");
					return false;
			}
		}
		if($.trim(pageSize)==""){
			alert("每页显示数不应许为空");
			return false;
		}
		doSubmit();
	}
	
	function gotoJumpPage(){
		var jumpNum= $("#jumpNum").val();
		$("#search_page_size").val($("#id_page_size").val());
		gotoPage(jumpNum);
		return false;
	}

	function oper(id,type){
		console.log(type)
		if('detail'==type){
			window.location.href= "${pageContext.request.contextPath }/backend/merchant/showMerchant?id="+id+"&type=detail";
		}
		if('edit'==type){
			window.location.href= "${pageContext.request.contextPath }/backend/merchant/showMerchant?id="+id+"&type=edit";
		}
		
		if('add'==type){
			window.location.href= "${pageContext.request.contextPath }/backend/merchant/showMerchant?type=add";
		}
		if('view'==type){
			window.location.href= "${pageContext.request.contextPath }/backend/merchantDetail/search?merchantId="+id;
		}
		if('del'==type){
			 $.dialog.confirm({title:"删除",content:"您确定要删除吗",callback:"deleteData('"+id+"');"});
		}
		
	}

	function deleteData(id){
		$.ajax({
			url:"${pageContext.request.contextPath }/backend/merchant/deleteById",
			type: 'POST',
			data:{'id':id},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				$.dialog.alert({title:"删除",content:"加载数据异常"});
			},
			success: function(data){
				if(data.result==1) {
					$.dialog.alert({title:"删除",content:"删除成功"});
					searchData();
				} else {
					$.dialog.alert({title:"删除",content:"删除失败:"+data.errorMessage});
				}
			}
		});
	}
</script>
</body>
</html>